using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EntLibEC.Biz.Online;
using EntLibEC.Cmn;

namespace EntLibEC.View.Online
{
    public partial class SearchKeyword : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.txtStartDate.Attributes["onclick"] = "javascript:calendar()";
            this.txtEndDate.Attributes["onclick"] = "javascript:calendar()";

            if (!Page.IsPostBack)
            {
                this.txtStartDate.Text = DateTime.Today.AddDays(-1).ToString(AppConst.DateFormat);
                this.txtEndDate.Text = DateTime.Now.ToString(AppConst.DateFormat);
            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            DateTime? fromDateTime = null;
            DateTime? toDateTime = null;

            if (txtStartDate.Text.Trim().Length > 0)
            {
                fromDateTime = DateTime.Parse(txtStartDate.Text.Trim());
            }

            if (txtEndDate.Text.Trim().Length > 0)
            {
                toDateTime = DateTime.Parse(txtEndDate.Text.Trim());
                toDateTime = toDateTime.Value.AddDays(1);
            }

            ds = SearchKeywordManager.Query(fromDateTime, toDateTime);

            grdKeyword.DataSource = ds;
            grdKeyword.DataBind();
        }
    }
}
